'use strict';

var mongoose = require('mongoose'),
    Schema = mongoose.Schema,
    baseController = require('../../../Base/server/controllers/BaseDoc.js');

var newModel = baseController.getBaseDocFields();
newModel.Code = {
    type: String,
    unique: '编码已存在',
    required: '请输入编码',
    trim: true
};
newModel.Name = {
    type: String,
    required: '请输入名称',
    trim: true
};
//规格
newModel.Specification = {
    type: String,
    default: '',
    trim: true
};
//料品分类
newModel.ItemCategory = {
    type: Number
};
newModel.IsEffective = {
    type: Boolean
};
//ERP系统里面对应的实体ID
newModel.ErpId = {
    type: String,
    trim: true
};
newModel.Remark = {
    type: String,
    default: '',
    trim: true
};

var newSchema = new Schema(newModel);
newSchema.index({Name: 1});
newSchema.index({Code: 1}, {"unique": true});

mongoose.model('ItemMaster', newSchema, 'ItemMaster');
